package com.example.wzviewer;

import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;

import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.example.wzviewer.widget.Media3VideoView;

public class MainActivity extends AppCompatActivity {

    //定义视频视图
    private Media3VideoView videoView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //保持屏幕常亮
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        //隐藏状态栏 需添加ImmersionBar依赖
        ImmersionBar.with(this).hideBar(BarHide.FLAG_HIDE_STATUS_BAR).init();

        super.onCreate(savedInstanceState);

        //setContentView(R.layout.activity_main);

        setContentView(R.layout.activity_player);
        videoView=findViewById(R.id.player_view);

        videoView.play(Uri.parse("asset:///video/720p_3.mp4"));


        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }


    @Override protected void onPause()  { super.onPause();  videoView.pause(); }
    @Override protected void onResume() { super.onResume(); videoView.resumePlay(); }
    @Override protected void onDestroy(){ super.onDestroy(); videoView.release(); }

}